#region License
// ShammatehMasterDetailCrudViewModel.cs
// 
// Copyright (c) 2012 Xoqal.com
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

namespace Shammateh.Win.UI.ViewModels
{
    using Xoqal.Presentation.ViewModels;

    /// <summary>
    /// Represents the base functionality for a maize master-detail view-model CRUD operation.
    /// </summary>
    public class ShammatehMasterDetailCrudViewModel<TMasterViewModel, TDetailViewModel> :
        MasterDetailViewModel<TMasterViewModel, TDetailViewModel>,
        IShammatehMasterDetailCrudViewModel
        where TMasterViewModel : class, IItemCollectionViewModel, IRefreshableViewModel
        where TDetailViewModel : class, IDetailViewModel, IRefreshableViewModel
    {
        #region Fields

        private bool isOperationPanelExpanded;
        private int operationTabControlSelectedIndex;

        #endregion

        #region Contructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ShammatehMasterDetailCrudViewModel&lt;TMasterViewModel, TDetailViewModel&gt;"/> class.
        /// </summary>
        /// <param name="masterViewModel">The master view model.</param>
        /// <param name="detailViewModel">The detail view model.</param>
        public ShammatehMasterDetailCrudViewModel(TMasterViewModel masterViewModel, TDetailViewModel detailViewModel)
            : base(masterViewModel, detailViewModel)
        {
            ((IMasterDetailContent)masterViewModel).MasterViewModel = this;
            ((IMasterDetailContent)detailViewModel).MasterViewModel = this;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the index of the operation tab control selected.
        /// </summary>
        /// <value>The index of the operation tab control selected.</value>
        public int OperationTabControlSelectedIndex
        {
            get 
            {
                return this.operationTabControlSelectedIndex; 
            }

            set
            {
                if (this.operationTabControlSelectedIndex == value)
                {
                    return;
                }

                this.operationTabControlSelectedIndex = value;
                this.RaisePropertyChanged(() => this.OperationTabControlSelectedIndex);
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is operation panel expanded.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is operation panel expanded; otherwise, <c>false</c>.
        /// </value>
        public bool IsOperationPanelExpanded
        {
            get 
            { 
                return this.isOperationPanelExpanded; 
            }

            set
            {
                if (this.isOperationPanelExpanded == value)
                {
                    return;
                }

                this.isOperationPanelExpanded = value;
                this.RaisePropertyChanged(() => this.IsOperationPanelExpanded);
            }
        }

        #endregion

        #region Protected Methods

        #endregion
    }
}
